<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button class="btn">提交JSON</button>
    <script>
        const headers = {
            'Content-Type': 'application/json'
        }
        document.querySelector('.btn').addEventListener('click', async () => {
            const res = await fetch('http://hmajax.itheima.net/api/register', {
                method: 'POST',
                headers: headers,
                body: JSON.stringify({
                    username: 'itheima666',
                    password: '123456'
                })
            })

        })
    </script>
</body>

</html>